/*
 * Copyright (C) 2012 Matthias Zeimer and the miniframes community.
 * All rights reserved. 
 * 
 * Licensed under the Eclipse Public License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.opensource.org/licenses/EPL-1.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.miniframes.minijpa;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceException;

/**
 * <p>
 * A factory for {@link DatabaseInterfaceProvider}.
 * </p>
 * 
 * @author Matthias Zeimer
 * @version 1
 * @since 0.1, 19.06.2012
 */
public class DatabaseInterfaceProviderFactory {

    protected final EntityManagerFactory entityManagerFactory;
    protected final EntityManager createEntityManager;

    /**
     * Creates a new factory based on the settings of the specified
     * {@link EntityManagerFactory}.
     * 
     * @param entityManagerFactory
     *            The factory to base on. It must be able to provide an
     *            {@link EntityManager}.
     * @throws NullPointerException
     *             if {@code entityManagerFactory} is <code>null</code>.
     * @throws IllegalStateException
     *             if {@code entityManagerFactory} is closed.
     */
    public DatabaseInterfaceProviderFactory(
                                    EntityManagerFactory entityManagerFactory)
                                    throws NullPointerException,
                                    IllegalStateException {
        this.entityManagerFactory = entityManagerFactory;
        this.createEntityManager = entityManagerFactory.createEntityManager();
    }

    /**
     * <p>
     * Creates a database interface provider of type T.
     * </p>
     * 
     * @param databaseInterfaceDeclaration
     * @return The provider of type T, subsequent calls will create new
     *         instances.
     * @throws NullPointerException
     * @throws IllegalArgumentException
     * @throws PersistenceException
     */
    public <T> DatabaseInterfaceProvider<T> createProviderOf(
                                    Class<T> databaseInterfaceDeclaration)
                                    throws NullPointerException,
                                    IllegalArgumentException,
                                    PersistenceException {
        return null; // TODO need to be implemented.
    }

}
